﻿<!DOCTYPE html>
<html>
<head>
    <title>锐浪HTML5报表演示 - 根据报表模板中的SQL获取报表数据</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <script src="../../grhtml5-6.6-min.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
        function window_onload() {
            var reportViewer = rubylong.grhtml5.insertReportViewer("report_holder", "../../../grf/9b.grf");

            //本例子演示如何根据报表模板中的查询SQL设置获取报表数据
            //只有当报表模板已经载入后，才能获取到报表模板中的查询SQL，
            //所以必须在报表查看器的 onReportLoaded 事件响应函数中处理报表数据任务
            reportViewer.events.onReportLoaded = onReportLoaded;

            reportViewer.start(); //启动报表运行，生成报表
        }

        function onReportLoaded(viewer) {
            var report = viewer.report,
                masterSQL = report.QuerySQL,
                detailSQL = report.DetailGrid ? report.DetailGrid.Recordset.QuerySQL : "",
                url = "../../../data/SQLParam.jsp?QuerySQL=";

            if (!masterSQL && detailSQL) {
                masterSQL = detailSQL;
                detailSQL = "";
            }
            url += encodeURIComponent(masterSQL)
            if (detailSQL) {
                url += "&QuerySQL2=" + encodeURIComponent(detailSQL);
            }

            window.rubylong.ajax(url, function (xmlhttp, success) {
                this.loadData(xmlhttp, success, 1);
            }, viewer);

            viewer.waitData = true; //阻止在报表模板定义后直接生成报表
        };
    </script>
</head>
<body onload="window_onload()">
    <div id="report_holder">
    </div>
</body>
</html>